<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2015/12/21 0021
 * Time: 上午 11:29
 */
$vote = $_REQUEST['vote'];

$filename="poll_result.txt";
$content=file($filename);

$array = explode("||",$content[0]);
$yes=$array[0];
$no=$array[1];

if($vote == 0){
    $yes = $yes +1;
}
if($vote == 1){
    $no=$no +1;
}

$insertvote=$yes."||".$no;
$fp = fopen($filename,"w");
fputs($fp,$insertvote);
fclose($fp);
?>
<h2>Result:</h2>
<table>
    <tr>
        <td>Yes:</td>
        <td>
            <img src="poll.gif"
                width='<?php echo(100*round($yes/($yes+$no),2));?>'
                height='20'>
            <?php echo(100*round($yes/($yes+$no),2));?>
        </td>
    </tr>
    <tr>
        <td>No:</td>
        <td>
            <img src="poll.gif"
                 width='<?php echo(100*round($no/($yes+$no),2));?>'
                 height='20'>
            <?php echo(100*round($no/($yes+$no),2));?>
        </td>
    </tr>
</table>
